package com.milk.nettylearn.nio.c4;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.nio.charset.Charset;

public class WriteClient {
    public static void main(String[] args) throws IOException {
        SocketChannel socketChannel = SocketChannel.open();
        socketChannel.connect(new InetSocketAddress(8080));

        ByteBuffer byteBuffer = Charset.defaultCharset().encode("hello");
        socketChannel.write(byteBuffer);

//        int count = 0;
//        while (true) {
//            ByteBuffer buffer = ByteBuffer.allocate(1024 * 1024);
//            count += socketChannel.read(buffer);
//            System.out.println("count:" + count);
//        }
        System.in.read();
    }
}
